package com.aabte.design2.creational.prototype;

import java.util.LinkedList;
import java.util.List;

/**
 * @author Daniel
 * @version 1.0
 * @date 2020/5/3
 */
public class Application {

    private List<Shape> shapes = new LinkedList<>();

    public static void main(String[] args) {
        new Application().businessLogic();
    }

    public Application() {
        Circle circle = new Circle();
        circle.setX(10).setY(10);
        circle.setRadius(20);
        shapes.add(circle);

        Circle anotherCircle = circle.clone();
        shapes.add(anotherCircle);

        Rectangle rectangle = new Rectangle().setWidth(10).setHeight(20);
        shapes.add(rectangle);
        shapes.add(rectangle.clone());
    }

    public void businessLogic() {
        List<Shape> shapesCopy = new LinkedList<>();
        for (Shape shape : shapes) {
            shapesCopy.add(shape.clone());
        }
        System.out.println("shapesCopy = " + shapesCopy);
    }
}
